<!DOCTYPE HTML>
<html lang="en" >
    <!-- Start book 我的电子书 -->
    <head>
        <!-- head:start -->
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <title>定位 | 我的电子书</title>
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <meta name="description" content="">
        <meta name="generator" content="GitBook 2.6.9">
        <meta name="author" content="Melon">
        
        <meta name="HandheldFriendly" content="true"/>
        <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../../gitbook/images/apple-touch-icon-precomposed-152.png">
        <link rel="shortcut icon" href="../../gitbook/images/favicon.ico" type="image/x-icon">
        
    <link rel="stylesheet" href="../../gitbook/style.css">
    
        
        <link rel="stylesheet" href="../../gitbook/plugins/gitbook-plugin-toggle-chapters/toggle.css">
        
    
        
        <link rel="stylesheet" href="../../gitbook/plugins/gitbook-plugin-image-captions/image-captions.css">
        
    
        
        <link rel="stylesheet" href="../../gitbook/plugins/gitbook-plugin-highlight/website.css">
        
    
        
        <link rel="stylesheet" href="../../gitbook/plugins/gitbook-plugin-fontsettings/website.css">
        
    
    

        
    
    
    <link rel="next" href="../../md/02css/textoverflow.html" />
    
    
    <link rel="prev" href="../../md/02css/media.html" />
    

        <!-- head:end -->
    </head>
    <body>
        <!-- body:start -->
        
    <div class="book"
        data-level="2.7"
        data-chapter-title="定位"
        data-filepath="md/02css/position.md"
        data-basepath="../.."
        data-revision="Mon Jun 08 2020 19:44:34 GMT+0800 (中国标准时间)"
        data-innerlanguage="">
    

<div class="book-summary">
    <nav role="navigation">
        <ul class="summary">
            
            
            
            

            

            
    
        <li class="chapter " data-level="0" data-path="index.html">
            
                
                    <a href="../../index.html">
                
                        <i class="fa fa-check"></i>
                        
                        Introduction
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1" data-path="md/01html/01label.html">
            
                
                    <a href="../../md/01html/01label.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.</b>
                        
                        HTML标签
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.1" data-path="md/01html/boxmodel.html">
            
                
                    <a href="../../md/01html/boxmodel.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.1.</b>
                        
                        盒子模型
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="md/01html/nvmgitbook.html">
            
                
                    <a href="../../md/01html/nvmgitbook.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.2.</b>
                        
                        nvm和gitbook
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2" data-path="md/02css/index.html">
            
                
                    <a href="../../md/02css/index.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.</b>
                        
                        css
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.1" data-path="md/02css/01selector.html">
            
                
                    <a href="../../md/02css/01selector.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.1.</b>
                        
                        选择器
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.2" data-path="md/02css/element_center.html">
            
                
                    <a href="../../md/02css/element_center.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.2.</b>
                        
                        元素垂直居中的方法
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.3" data-path="md/02css/Interview.html">
            
                
                    <a href="../../md/02css/Interview.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.3.</b>
                        
                        面试题
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.4" data-path="md/02css/displayvisibility.html">
            
                
                    <a href="../../md/02css/displayvisibility.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.4.</b>
                        
                        元素的显示模式
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.5" data-path="md/02css/float.html">
            
                
                    <a href="../../md/02css/float.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.5.</b>
                        
                        浮动
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.6" data-path="md/02css/media.html">
            
                
                    <a href="../../md/02css/media.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.6.</b>
                        
                        media媒体查询
                    </a>
            
            
        </li>
    
        <li class="chapter active" data-level="2.7" data-path="md/02css/position.html">
            
                
                    <a href="../../md/02css/position.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.7.</b>
                        
                        定位
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.8" data-path="md/02css/textoverflow.html">
            
                
                    <a href="../../md/02css/textoverflow.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.8.</b>
                        
                        文本溢出处理
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    


            
            <li class="divider"></li>
            <li>
                <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
                    Published with GitBook
                </a>
            </li>
            
        </ul>
    </nav>
</div>

    <div class="book-body">
        <div class="body-inner">
            <div class="book-header" role="navigation">
    <!-- Actions Left -->
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="../../" >我的电子书</a>
    </h1>
</div>

            <div class="page-wrapper" tabindex="-1" role="main">
                <div class="page-inner">
                
                
                    <section class="normal" id="section-">
                    
                        <h1 id="&#x5B9A;&#x4F4D;position&#x548C;zindex">&#x5B9A;&#x4F4D;position&#x548C;z-index</h1>
<h3 id="&#x5B9A;&#x4F4D;&#xFF1A;&#x4E00;&#x79CD;&#x66F4;&#x9AD8;&#x7EA7;&#x7684;&#x5E03;&#x5C40;&#x624B;&#x6BB5;&#xFF0C;&#x901A;&#x8FC7;&#x5B9A;&#x4F4D;&#x53EF;&#x4EE5;&#x5C06;&#x5143;&#x7D20;&#x653E;&#x5728;&#x4EFB;&#x610F;&#x4F4D;&#x7F6E;&#x3002;">&#x5B9A;&#x4F4D;&#xFF1A;&#x4E00;&#x79CD;&#x66F4;&#x9AD8;&#x7EA7;&#x7684;&#x5E03;&#x5C40;&#x624B;&#x6BB5;&#xFF0C;&#x901A;&#x8FC7;&#x5B9A;&#x4F4D;&#x53EF;&#x4EE5;&#x5C06;&#x5143;&#x7D20;&#x653E;&#x5728;&#x4EFB;&#x610F;&#x4F4D;&#x7F6E;&#x3002;</h3>
<h4 id="1-&#x7EDD;&#x5BF9;&#x5B9A;&#x4F4D;absolute">1. &#x7EDD;&#x5BF9;&#x5B9A;&#x4F4D;<code>absolute</code></h4>
<pre><code class="lang-css"><span class="hljs-rules">{
    <span class="hljs-rule"><span class="hljs-attribute">top</span>:<span class="hljs-value"><span class="hljs-number">0</span></span></span>;
    <span class="hljs-rule"><span class="hljs-attribute">left</span>:<span class="hljs-value"><span class="hljs-number">0</span></span></span>;
    <span class="hljs-rule"><span class="hljs-attribute">bottom</span>:<span class="hljs-value"><span class="hljs-number">0</span></span></span>;
    <span class="hljs-rule"><span class="hljs-attribute">right</span>:<span class="hljs-value"><span class="hljs-number">0</span></span></span>;
}</span>
</code></pre>
<ul>
<li>&#x5B9A;&#x4F4D;&#x5728;<code>position</code>&#x4E3A;&#x975E;<code>static</code>&#x7684;&#x5143;&#x7D20;&#x8EAB;&#x4E0A;&#xFF0C;&#x53E3;&#x8BC0;&#xFF1A;&#x201C;&#x5B50;&#x7EDD;&#x7236;&#x76F8;&#x201D;&#x662F;&#x6307;&#x5B9A;&#x4F4D;&#x5230;&#x6709;&#x8BBE;&#x7F6E;<code>relative</code>&#x76F8;&#x5BF9;&#x5B9A;&#x4F4D;&#x7684;&#x5143;&#x7D20;&#x8EAB;&#x4E0A;&#xFF0C;&#x5982;&#x679C;&#x6CA1;&#x6709;&#x8BBE;&#x7F6E;&#x76F8;&#x5BF9;&#x5B9A;&#x4F4D;&#x7684;&#x7236;&#x5143;&#x7D20;&#x5C31;&#x4F1A;&#x5B9A;&#x4F4D;&#x5230;&#x6D4F;&#x89C8;&#x5668;&#x4E0A;&#xFF0C;&#x4F1A;&#x8986;&#x76D6;&#x539F;&#x6709;&#x7684;&#x5143;&#x7D20;&#x4E0A;&#x9762;&#x3002;</li>
</ul>
<h4 id="2-&#x76F8;&#x5BF9;&#x5B9A;&#x4F4D;relative">2. &#x76F8;&#x5BF9;&#x5B9A;&#x4F4D;<code>relative</code></h4>
<pre><code class="lang-css"><span class="hljs-rules">{
    <span class="hljs-rule"><span class="hljs-attribute">top</span>:<span class="hljs-value"><span class="hljs-number">0</span></span></span>;
    <span class="hljs-rule"><span class="hljs-attribute">left</span>:<span class="hljs-value"><span class="hljs-number">0</span></span></span>;
    <span class="hljs-rule"><span class="hljs-attribute">bottom</span>:<span class="hljs-value"><span class="hljs-number">0</span></span></span>;
    <span class="hljs-rule"><span class="hljs-attribute">right</span>:<span class="hljs-value"><span class="hljs-number">0</span></span></span>;
}</span>
</code></pre>
<ul>
<li>&#x57FA;&#x4E8E;&#x5143;&#x7D20;&#x672C;&#x8EAB;&#x7684;&#x5B9A;&#x4F4D;&#xFF0C;&#x5F53;<code>left</code>&#x8D8A;&#x5927;&#xFF0C;&#x5B9A;&#x4F4D;&#x5143;&#x7D20;&#x8D8A;&#x5411;&#x53F3;&#xFF0C;&#x5F53;<code>right</code>&#x8D8A;&#x5927;&#xFF0C;&#x5B9A;&#x4F4D;&#x5143;&#x7D20;&#x8D8A;&#x5411;&#x5DE6;&#x79FB;&#xFF0C;&#x5F53;<code>top</code>&#x8D8A;&#x5927;&#xFF0C;&#x5B9A;&#x4F4D;&#x5143;&#x7D20;&#x8D8A;&#x5411;&#x4E0B;&#x5F53;<code>bottom</code>&#x8D8A;&#x5927;&#xFF0C;&#x5B9A;&#x4F4D;&#x5143;&#x7D20;&#x8D8A;&#x5411;&#x4E0A;&#xFF0C;&#x901A;&#x5E38;&#x6765;&#x8BF4;&#xFF0C;&#x4EC5;&#x7528;&#x4E8E;&#x8F85;&#x52A9;&#x201C;&#x7EDD;&#x5BF9;&#x5B9A;&#x4F4D;&#x201D;&#x3002;</li>
</ul>
<h4 id="3-&#x56FA;&#x5B9A;&#x5B9A;&#x4F4D;fixed">3. &#x56FA;&#x5B9A;&#x5B9A;&#x4F4D;<code>fixed</code></h4>
<pre><code class="lang-css"><span class="hljs-rules">{
    <span class="hljs-rule"><span class="hljs-attribute">top</span>:<span class="hljs-value"><span class="hljs-number">0</span></span></span>;
    <span class="hljs-rule"><span class="hljs-attribute">left</span>:<span class="hljs-value"><span class="hljs-number">0</span></span></span>;
    <span class="hljs-rule"><span class="hljs-attribute">bottom</span>:<span class="hljs-value"><span class="hljs-number">0</span></span></span>;
    <span class="hljs-rule"><span class="hljs-attribute">right</span>:<span class="hljs-value"><span class="hljs-number">0</span></span></span>;
}</span>
</code></pre>
<ul>
<li>&#x8131;&#x79BB;&#x6587;&#x6863;&#x6D41;&#xFF0C;&#x662F;&#x57FA;&#x4E8E;&#x6D4F;&#x89C8;&#x5668;&#x57FA;&#x7EBF;&#x7684;&#x5B9A;&#x4F4D;&#xFF0C;&#x7279;&#x70B9;&#xFF1A;&#x4E0D;&#x4F1A;&#x968F;&#x7740;&#x6D4F;&#x89C8;&#x5668;&#x7684;&#x6EDA;&#x52A8;&#x800C;&#x6539;&#x53D8;&#x4F4D;&#x7F6E;&#x3002;</li>
</ul>
<h3 id="zindex">z-index</h3>
<ul>
<li><code>z-index</code>&#x5C42;&#x53E0;&#x4F18;&#x5148;&#x7EA7;<ul>
<li>&#x53EF;&#x4EE5;&#x8BBE;&#x7F6E;&#x5B9A;&#x4F4D;&#x5C5E;&#x6027;&#x7684;&#x5143;&#x7D20;&#x663E;&#x793A;&#x7684;&#x4F4D;&#x7F6E;&#xFF0C;&#x503C;&#x8D8A;&#x5927;&#x4F18;&#x5148;&#x663E;&#x793A;&#x5C42;&#x5C31;&#x8D8A;&#x9AD8;&#xFF0C;&#x53EF;&#x4EE5;&#x4E3A;&#x8D1F;&#x503C;</li>
</ul>
</li>
</ul>

                    
                    </section>
                
                
                </div>
            </div>
        </div>

        
        <a href="../../md/02css/media.html" class="navigation navigation-prev " aria-label="Previous page: media媒体查询"><i class="fa fa-angle-left"></i></a>
        
        
        <a href="../../md/02css/textoverflow.html" class="navigation navigation-next " aria-label="Next page: 文本溢出处理"><i class="fa fa-angle-right"></i></a>
        
    </div>
</div>

        
<script src="../../gitbook/app.js"></script>

    
    <script src="../../gitbook/plugins/gitbook-plugin-toggle-chapters/toggle.js"></script>
    

    
    <script src="../../gitbook/plugins/gitbook-plugin-fontsettings/buttons.js"></script>
    

<script>
require(["gitbook"], function(gitbook) {
    var config = {"image-captions":{"attributes":{"style":"left: 50%;position: relative;transform: translateX(-50%);"},"caption":"图 _PAGE_LEVEL_._PAGE_IMAGE_NUMBER_ - _CAPTION_","align":"center","variable_name":"_pictures"},"fontsettings":{"theme":"night","family":"sans","size":2},"toggle-chapters":{},"highlight":{}};
    gitbook.start(config);
});
</script>

        <!-- body:end -->
    </body>
    <!-- End of book 我的电子书 -->
</html>
